if (typeof Pyforum == 'undefined') {
    var PyforumJS = {__namespace: true};
}

// IEF Pattern
PyforumJS.Controller = (function () {
    return {
        Helper: (function () {
            return {
                changeUser: function () {
                    var msg = 'In order to change your username ' +
                    'you need to go to the User\'s preferece ' +
                    'area and update the \'forum username\' field.';
                    alert(msg);
                }
            }
        }()),
        lineIze: function () {
            $("pre code").html(function(index, html) {
                return html.replace(/^(.*)$/mg, "<span class=\"line\">$1</span>")
            });
        },
        initTextareaEditor: function () {
            // Change this i you want to include your own (or empty) text area editor
            //this._sceditor();
            //this._tinymce();
        },
        _tinymce: function () {
            tinymce.init({
                selector: "textarea",
                plugins: [
                    "advlist autolink lists link image charmap preview",
                    "searchreplace code hr wordcount",
                    "insertdatetime media table contextmenu paste"
                ],
                toolbar: "preview paste | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
            });
        },
        _sceditor: function () {
            // http://www.sceditor.com/
            $("textarea").sceditor({
		plugins: 'xhtml',
		style: '/pyforum2/static/js/sceditor/minified/jquery.sceditor.default.min.css',
                emoticonsRoot: '/pyforum2/static/js/sceditor/',
                fonts: 'Open Sans,Verdana,sans-serif',
                width: null,
                toolbarExclude: 'ltr,rtl,print,maximize,font',
                resizeEnabled: false
            });
        }
    }
}())
